using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Entities;
using Utility;
namespace BUS
{
    public class tbAmthucBUS
    {
        public static void Insert(tbAmthuc at)
        {
            tbAmthucDAL atDAL = new tbAmthucDAL();
            atDAL.Insert(at);
        }
        public static void Update(tbAmthuc at)
        {
            tbAmthucDAL atDAL = new tbAmthucDAL();
            atDAL.Update(at);
        }
        //public static void Updatettsp(tbSanpham sp)
        //{
        //    tbSanphamDAL spDAL = new tbSanphamDAL();
        //    spDAL.Updatettsp(sp);
        //}
        //public static void Updatetlck(tbSanpham sp)
        //{
        //    tbSanphamDAL spDAL = new tbSanphamDAL();
        //    spDAL.Updatetlck(sp);
        //}
        //public static void Updatettdn(tbSanpham sp)
        //{
        //    tbSanphamDAL spDAL = new tbSanphamDAL();
        //    spDAL.Updatettdn(sp);
        //}
        public static void Delete(int iD)
        {
            tbAmthucDAL atDAL=new tbAmthucDAL();
            atDAL.Delete(iD);
        }
        public static tbAmthucCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbAmthucDAL atDAL = new tbAmthucDAL();
            return atDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbAmthucCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbAmthucDAL atDAL = new tbAmthucDAL();
            return atDAL.Get(cri.Criter, 0, 0, tbAmthucCollumn.maamthuc.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbAmthuc GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbAmthucCollumn.maamthuc.ToString(), Condition.EQUAL, iD);
            tbAmthucDAL atDAL = new tbAmthucDAL();
           tbAmthucCollection atColl = atDAL.Get(cri.Criter, 0, 0, tbAmthucCollumn.maamthuc.ToString(), OrderDirection.ASC.ToString(), out total);
            if (atColl.Count > 0)
                return atColl[0];
            return null;
        }
        public static tbAmthucCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbAmthucDAL atDAL = new tbAmthucDAL();
            return atDAL.Get(cri.Criter, 1, number,
             tbAmthucCollumn.maamthuc.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbAmthucCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbAmthucDAL atDAL = new tbAmthucDAL();
            return atDAL.Get(cri.Criter, 1, number,
            tbAmthucCollumn.maamthuc.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
